﻿<script src="http://code.jquery.com/jquery-1.4.3.min.js" type="text/javascript"></script>

<style>
    /* css pour la tooltip lien avec preview */
    #screenshot
    {
        position: absolute;
        border: 1px solid #ccc;
        background: #333;
        padding: 5px;
        display: none;
        color: #fff;
    }
    /* css pour la tooltip image preview */
    #preview
    {
        position: absolute;
        border: 1px solid #ccc;
        background: #333;
        padding: 5px;
        display: none;
        color: #fff;
    }
    /* css pour la tooltip normal */
    #tooltip
    {
        position: absolute;
        border: 1px solid #333;
        background: #f7f5d1;
        padding: 2px 5px;
        color: #333;
        display: none;
    }
</style>
<script type="text/javascript">
    // Define the entry point
    $(document).ready(function () {
        // The DOM (document object model) is constructed
        // We will initialize and run our plugin here
        screenshotPreview();
    });

    this.screenshotPreview = function () {
        /* CONFIG */

        xOffset = 10;
        yOffset = 30;

        // these 2 variable determine popup's distance from the cursor
        // you might want to adjust to get the right result

        /* END CONFIG */
        $(".ms-rtestate-field a").hover(function (e) {
            if ($(this).attr('href') == "")
                return;
            this.t = this.title;
            this.title = "";
            var c = (this.t != "") ? "<br/>" + this.t : "";
            $("body").append("<p id='screenshot'><img src=\"/_layouts/SPThumbnailExtender/MobileGenericHandler.ashx?doc=" + $(this).attr('href') + "\" alt='url preview' />" + c + "</p>");
            $("#screenshot")
                        .css("top", (e.pageY - xOffset) + "px")
                        .css("left", (e.pageX + yOffset) + "px")
                        .fadeIn("fast");
        },
        function () {
            this.title = this.t;
            $("#screenshot").remove();
        });
        $("a.screenshot").mousemove(function (e) {
            $("#screenshot")
                        .css("top", (e.pageY - xOffset) + "px")
                        .css("left", (e.pageX + yOffset) + "px");
        });
    };
</script>